<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib prefix="sys" tagdir="/WEB-INF/tags/sys"%>
<%@taglib uri="/WEB-INF/tlds/webui.tld" prefix="webui"%>

<!-- 内容类型 -->
<webui:enum var="contentType" code="contentType"/>
<webui:enum var="exclusiveTypeEnum" code="exclusive"/>
<webui:enum var="vodAreaTypeEnum" code="vodArea"/>
<webui:enum var="mergerTypeEnum" code="mergerType"/>
<webui:enum var="isAdoptedType" code="isAdoptedType"/>
<webui:enum var="cpNameTypeEnum" code="cpNameType"/>
<webui:enum var="orgEnum" code="OrgEnum" appendJs="true"/>

<script>
//组织名称
function tableOrgEnum(table,data){
	var logs = data.data.content;
	$(logs).each(function(index,element){
		var _self = this;
		var orgName = orgEnum[element.cpContent.orgId];
		Vue.set(_self,"orgName",orgName);
	});
	var contentCount = data.page.totalElements;
	if(!document.getElementById("table_length")){
		$("#grid_queryDeclare_paginate").parent().prev().append("<div id='table_length' style='float:left'></div>");
	}
	if (contentCount > 0) {
		$("#table_length").html("共"+contentCount+"条数据");
	} else {
		$("#table_length").html("");
	}
}
</script>

<webui:panel id="queryDeclare">
	<%-- -----------------筛选条件 start------------------ --%>
	<webui:form method="get" styleClass="form-horizontal" 
		name="declareSearchForm" id="declareSearchForm"
		action="${contextPath}/getUnitContentCPContent.action">
		<webui:select label="CP名称" styleClass="col-sm-4" labelClass="col-sm-4" 
			inputClass="col-sm-8" name="orgId" id="mergerType" lookup="${orgEnum}" 
			multiple="false">
		</webui:select>
		<webui:input label="片名" styleClass="col-sm-4" labelClass="col-sm-4"
			inputClass="col-sm-8" type="text" name="cpName">
		</webui:input>
		<webui:input label="归并名称" styleClass="col-sm-4" labelClass="col-sm-4"
			inputClass="col-sm-8" type="text" name="name">
		</webui:input>
		<webui:select label="内容类型" styleClass="col-sm-4" labelClass="col-sm-4" 
			inputClass="col-sm-8" name="contentType" id="contentTypeSelectList" lookup="${contentType}" 
			multiple="false">
		</webui:select>
		<webui:select label="是否采纳" styleClass="col-sm-4" labelClass="col-sm-4" 
			inputClass="col-sm-8" name="isAdopted" id="isAdoptedType" lookup="${isAdoptedType}" 
			multiple="false">
		</webui:select>
		<webui:select label="归并状态" styleClass="col-sm-4" labelClass="col-sm-4" 
			inputClass="col-sm-8" name="mergerType" id="mergerType" lookup="${mergerTypeEnum}" 
			multiple="false">
		</webui:select>
			
		<webui:datepicker label="申报时间"  styleClass="col-sm-5" name="startTime" labelClass="col-sm-4" 
			inputClass="col-sm-8" beginName="startDeclareTime" beginId="startDeclareTime" 
			endName="endDecalareTime" endId="endDecalareTime" duration="true">
		</webui:datepicker>
		<webui:datepicker label="上线时间"  styleClass="col-sm-5" name="startTime" labelClass="col-sm-4" 
			inputClass="col-sm-8" beginName="startOnLineTime" beginId="startOnLineTime" 
			endName="endOnLineTime" endId="endOnLineTime" duration="true">
		</webui:datepicker>
		<webui:button label="" type="button" styleClass="col-sm-2"
			labelClass="col-sm-1" inputClass="col-sm-3" buttonClass="btn-primary"
			onclick="grid_queryDeclare.filter()">
			查询
		</webui:button>
	</webui:form>
	<%-- -----------------筛选条件 end------------------ --%>
	
	<%-- -----------------数据显示 start------------------ --%>
	<webui:table  id="grid_queryDeclare" dataUrl="${contextPath}/getUnitContentCPContent.action?sort=id,desc" dataload="tableOrgEnum"
	datas="data.content" editorForm="#declareEditor" searchForm="#declareSearch" showToolbar="showToolbars" size="10">
		<webui:column field="orgName" title="CP名称" >{{row.orgName}}</webui:column>
		<webui:column field="name" title="片名">{{row.cpContent.name }}</webui:column>
		<webui:column field="contentType" title="类型"  lookup="${contentType}">	{{row.contentTypeDesc}}</webui:column>
	 	<webui:column field="name" title="归并名称">
			<div v-if="row.unitContent != null">{{row.unitContent.name}}</div>
	 	</webui:column>
		<webui:column field="unitContentId" title="归并状态">{{(row.cpContent.unitContentId != null && row.cpContent.unitContentId != '' ) ? '已归并':'未归并'}}</webui:column>
		<webui:column field="exclusive" title="是否独家">{{row.cpContent.exclusive == 1 ? '独家':'非独家' }}</webui:column>
		<webui:column field="isAdopted" title="采纳状态">
			<div v-if="row.cpContent.isAdopted == 0" class="text-center">
				未采纳
			</div>
			<div v-if="row.cpContent.isAdopted == 1" class="text-center">
				已采纳
			</div>
			<div v-if="row.cpContent.isAdopted == 2" class="text-center">
				待采纳
			</div>
		</webui:column>
		<webui:column field="zteCode" title="申报时间">{{row.cpContent.declareTime | moment("YYYY-MM-DD HH:mm:ss")}}</webui:column>
		<webui:column field="lastUpdateTime" title="修改时间">{{row.cpContent.lastUpdateTime | moment("YYYY-MM-DD HH:mm:ss")}}</webui:column>
		<webui:column field="ztePlayUrl" title="上线时间">{{row.cpContent.planOnlineTime | moment("YYYY-MM-DD HH:mm:ss")}}</webui:column>
	</webui:table>
	<%-- -----------------数据显示  end------------------ --%>
	
	<webui:button label="" type="button" styleClass="col-sm-2" onclick="exportExcel()"
			labelClass="col-sm-1" inputClass="col-sm-3" buttonClass="btn-primary">
			导出
	</webui:button>
	
</webui:panel>
<script>
$(function(){
	$("template").show(); 
});

//导出
function exportExcel(){
	//alert($("#declareSearchForm").serialize());
	$.ajax({
		method:'post',
		url:'${contextPath}/exportExcel.action',
		data:$("#declareSearchForm").serialize(),
		success:function(data){
			var fileName = data.data;
			var url = "${contextPath}"+fileName;
			window.open(url);
		}	
	});
}

</script>

